package com.eaoa.uc.account.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.eaoa.base.EABaseAction;
import com.eaoa.query.pub.PubAccountQuery;
import com.eaoa.uc.account.form.AccountCondition;
import com.eaoa.uc.account.form.AccountSearchForm;

public class AccountSelectDialogAction extends EABaseAction {
	protected ActionForward doWork(ActionMapping mapping, ActionForm form,
	HttpServletRequest request, HttpServletResponse response)
	throws Exception {

		AccountSearchForm aform = (AccountSearchForm) form;
		aform.initConditionPost();
		AccountCondition condition = (AccountCondition) aform
				.getCondition();

		PubAccountQuery query = new PubAccountQuery();
		query.setLazy(true);
		query.setLazyInitPubRoles(true);
		query.setName(condition.getName());
		query.setUsernameL(condition.getUsername());
		query.setIslock(condition.getIslock());
		query.setAccounttype(condition.getAccounttype());
		query.setPageRange(aform.getPageinfo());
		query.execute();

		request.setAttribute("results", query.getResults());

		return mapping.findForward("success");
	}

}